/**
 *  Authors:
 *  Scott Renaud
 *  Kevin Carrington
 * 
 *  Team 4 - Iteration 1
 *  COMP 354 / Winter 2012
 *  
 *  February 5 - 2012
 *  
 *  =============================
 *  
 *  Person.java
 *  
 *  This class creates a Person object that stores
 *  related information.
 *  
 *  Offers functionality to access and modify this said data.
 *  
 */

package taskManagmentSystem;

public class Person {
	
	// Class properties
	private String name = "";
	int totalHours = 0;
	private String listOfTasks = "";
	
	// Constructor
	public Person(String name)
	{
		this.name = name;
	}
	
	// Accessors and mutators  for the Person object
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getTotalHours() {
		return totalHours;
	}
	public void setTotalHours(int totalHours) {
		this.totalHours += totalHours;
	}
	public String getListOfTasks() {
		return listOfTasks;
	}
	
	// store the list of tasks associated with this Person
	public void setListOfTasks(String listOfTasks) {
		if ("".equals(this.listOfTasks))
		{
			this.listOfTasks += listOfTasks;
		}
		else
		{
			this.listOfTasks += " & " + listOfTasks;
		}
	}
	
	// overriding the toString method
	public String toString()
	{
		return name + ", " + totalHours + " hours, " + listOfTasks;
	}
	
	// overriding the equals method (defines how to compare two person objects)
	public boolean equals(Object other)
	{
		if(other == null) return false;
		if(other == this) return true;
		if(other.getClass() != this.getClass()) return false;
		
		Person otherPerson = (Person) other;
		return  ( otherPerson.getName().equalsIgnoreCase(this.getName()) && otherPerson.getTotalHours()==this.totalHours && otherPerson.getListOfTasks().equalsIgnoreCase(this.getListOfTasks()));

	}
	
}
